/**
 * @description 导航设置
*/

import * as Cesium from 'cesium'
import CesiumNavigation from 'cesium-navigation-es6'
import config from '../../config.js'

export default {
  // 设置罗盘
  setCompass (viewer, params) {
    params = params || {}
    let destination = params.destination || config.destination
    let { lng, lat, height } = destination
    const options = {}
    // 用于在使用重置导航重置地图视图时设置默认视图控制
    options.defaultResetView = Cesium.Cartographic.fromDegrees(lng, lat, height)
    // 用于启用或禁用罗盘
    options.enableCompass = params.enableCompass === undefined ? true : params.enableCompass
    // 用于启用或禁用缩放控件
    options.enableZoomControls = params.enableZoomControls === undefined ? true : params.enableZoomControls
    // 用于启用或禁用距离图例
    options.enableDistanceLegend = params.enableDistanceLegend === undefined ? true : params.enableDistanceLegend
    // 用于启用或禁用指南针外环
    options.enableCompassOuterRing = params.enableCompassOuterRing === undefined ? true : params.enableCompassOuterRing
    CesiumNavigation(viewer, options)
    // var options = {}
    // options.defaultResetView = Cesium.Cartographic.fromDegrees(lng, lat, height)
    // options.enableCompass = true // 显示罗盘
    // options.enableZoomControls = false // 显示缩放
    // options.enableDistanceLegend = true // 显示距离
    // options.enableCompassOuterRing = false // 应用导航插件
    // viewer.extend(Cesium.viewerCesiumNavigationMixin, options) // 设置最大俯仰角，[-90,-60]区间内，默认为-30，单位弧度
  }
}
